package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-07 17:19
 **/
public class LeetCode200 {

    //dfs+记忆化搜索
    /*int m;
    int n;

    public int numIslands(char[][] grid) {
        if (grid == null || grid.length == 0) {
            return 0;
        }

        m = grid.length;
        n = grid[0].length;
        boolean[][] visted = new boolean[m][n];
        int count = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j] == '1') {
                    if (visted[i][j]) {
                        continue;
                    }
                    ++count;
                    dfs(grid, i, j, visted);
                }

            }
        }

        return count;
    }

    void dfs(char[][] grid, int i, int j, boolean[][] visted) {
        if (i < 0 || j < 0 || i >= m || j >= n || grid[i][j] == '0' || visted[i][j]) {
            return;
        }

        visted[i][j] = true;
        dfs(grid, i - 1, j, visted);
        dfs(grid, i + 1, j, visted);
        dfs(grid, i, j - 1, visted);
        dfs(grid, i, j + 1, visted);
    }*/

}
